import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
import { defendRouter } from './defend'

const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}
Vue.use(VueRouter)

const routes = [

    {
        path: '/login',
        name: 'login',
        component: () =>
            import('../pages/login/login.vue')
    },
    {
        path: '/manage',
        name: 'manage',
        component: () =>
            import('../pages/layout/default.vue'),
        children: [{
            path: '/manage/index',
            meta: "系统首页",
            name: 'manage-index',
            component: () =>
                import('../pages/manage/manage.vue')
        },
        {
            path: '/manage/createForm',
            name: 'manage-createForm',
            component: () =>
                import('../pages/manage/createForm/createForm.vue')
        },
        {
            path: '/manage/table',
            name: 'manage-table',
            meta: "table表格",
            component: () =>
                import('../pages/manage/page/table.vue')
        },
        {
            path: '/manage/form',
            name: 'manage-form',
            meta: "表单相关",
            component: () =>
                import('../pages/manage/page/form.vue')
        },
        {
            path: '/manage/c',
            name: 'manage-c',
            meta: "c页面",
            component: () =>
                import('../pages/manage/layoutPages/c.vue')
        },
        {
            path: '/manage/d',
            name: 'manage-d',
            meta: "d页面",
            component: () =>
                import('../pages/manage/layoutPages/d.vue')
        },
        {
            path: '/manage/e',
            name: 'manage-e',
            meta: "e页面",
            component: () =>
                import('../pages/manage/layoutPages/e.vue')
        },
        {
            path: '/manage/f',
            name: 'manage-f',
            meta: "f页面",
            component: () =>
                import('../pages/manage/layoutPages/f.vue')
        },
        {
            path: '/manage/g',
            name: 'manage-g',
            meta: "g页面",
            component: () =>
                import('../pages/manage/layoutPages/g.vue')
        }
        ]
    },
    {
        path: '/design',
        name: 'design',
        component: () =>
            import('../pages/layout/designLayout.vue'),
        children: [{
            path: '/design/index',
            name: 'design-index',
            component: () =>
                import('../pages/design/index.vue')
        }, {
            path: '/design/preview',
            name: 'design-preview',
            component: () => import('../pages/design/preview.vue')
        },]
    },
    //拖拽设计页面
    {
        path: '/',
        name: 'Home',
        component: () => import('../pages/design/index.vue')
    },
    {
        path: '/about',
        name: 'About',
        component: () =>
            import('../views/About.vue')
    }
]

const router = new VueRouter({
    routes
})
//路由守卫
defendRouter(router)
export default router